﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pessoas</title>
</head>
<body>
<?php
$order = $_GET["order"];
echo "
<table> 
<tr> 
<td><a href='?order=nome'>NOME</a></td>
<td><a href='?order=cpf'>CPF</a></td>
<td>ADVOGADO</td>
<td><a href='?order=numerooab'>NUMERO OAB</a></td>
<td>UF OAB</td>
</tr>";
include '../conexao.php';
$res = mysql_query("SELECT * FROM PESSOAS ORDER BY ".$order." ASC");
$numerolinhas = mysql_num_rows($res);

while ($linha =  mysql_fetch_array($res)){
	  if($linha){
		  echo "<tr>";
         echo "<td>".$linha['nome']."</td>";
         echo "<td>".$linha['cpf']."</td>";
         echo "<td>".$linha['advogado']."</td>";
		 echo "<td>".$linha['numerooab']."</td>";
		 echo "<td>".$linha['ufoab']."</td>";
		 echo "</tr>";
    }else{
        echo "sem registro";
    }
}
echo "</table>";
echo $numerolinhas." Pessoas cadastradas!<br/>";
echo "Ordenado por ".$order;
?>
</body>
</html>